
import java.io.*;

public class DatoliteClassLoader extends ClassLoader {

    /**
     * Parent ClassLoader passed to this constructor
     * will be used if this ClassLoader can not resolve a
     * particular class.
     *
     * @param parent Parent ClassLoader
     *              (may be from getClass().getClassLoader())
     */
    public DatoliteClassLoader(ClassLoader parent) {
        super(parent);
    }
    
    public DatoliteClassLoader() {
    	super();
    }


    public Class<?> loadClass(String name) throws ClassNotFoundException {
    	try {
    	System.out.println("^^^^^^^^^^^^^^^^^^" + name);
        	return super.loadClass(name);
        } catch (Exception cnfe) {
        	cnfe.printStackTrace();
        	return null;
        }
    }

    /**
     * Loads a given file (presumably .class) into a byte array.
     * The file should be accessible as a resource, for example
     * it could be located on the classpath.
     *
     * @param name File name to load
     * @return Byte array read from the file
     * @throws IOException Is thrown when there
     *               was some problem reading the file
     */
    private byte[] loadClassData(String name) throws IOException {
        
        InputStream stream = getClass().getClassLoader().getResourceAsStream(name);
        int size = stream.available();
        byte buffer[] = new byte[size];
        
        DataInputStream in = new DataInputStream(stream);
        in.readFully(buffer);
        in.close();
        return buffer;
    }
}
